package com.wsz.cloud.core;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient    // 向服务发送中心注册成为服务的提供者
@EnableHystrix  // 添加Hystrix的支持
public class HystrixRibbonApplication {

	// 创建RestTemplate
	@Bean
	@LoadBalanced   // 必须配置LoadBalanced，其实现了默认的随机算法
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
	public static void main(String[] args) {
		SpringApplication.run(HystrixRibbonApplication.class, args);
	}
}
